package cn.com.cym.gamezao.entity.xmu;

import cn.com.cym.gamezao.annotation.Sensitive;
import cn.com.cym.gamezao.base.BaseEntity;
import cn.com.cym.gamezao.config.SensitiveStrategy;
import cn.com.cym.gamezao.entity.authorize.User;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonProperty;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.lang.NonNull;

import javax.persistence.*;
import java.io.Serializable;
import java.time.LocalDate;
import java.time.temporal.ChronoUnit;

@Setter
@Getter
@NoArgsConstructor
@Table(name = "x_recruit")
@Entity
@ApiModel(description = "招聘人员信息")
public class Recruit extends BaseEntity implements Serializable {
    private static final long serialVersionUID = 5721168039706893284L;


    @OneToOne
    @JoinColumn(name = "user_id")
    @JsonProperty(access = JsonProperty.Access.READ_WRITE)
    private User user;
    //应聘岗位信息
    /**
     *人员类别
     */
    @Column(length = 12)
    private String personType;

    ///**
     //* 申报岗位
     //*/
    /*  独立表格显示
    @Column(length = 12)
    private String applyJob;*/
    //应聘岗位信息
    /**
     * 头像  证件照
     */
    private Long picId;

    /**
     *第二联络人姓名
     */
    @Column(length = 36)
    private String secName;
    /**
     *第二联络人联系方法
     */
    @Column(length = 12)
    private String secTel;

    //个人基本信息
    /**
     * 姓名
     */
    @Column(length = 40)
    @NonNull
    private String name;

    /**
     * 性别
     */
    @NonNull
    @Column(length = 12)
    private String sex;

    /**
     * 证件类型
     */
    @Column(length = 24)
    @NonNull
    private String cardType;

    /**
     * 证件号
     */
    @Column(length = 24)
    @NonNull
    @Sensitive(strategy = SensitiveStrategy.ID_CARD)
    private String cardNo;


    @JsonFormat(pattern = "yyyy-MM-dd",timezone="GMT+8")
    @DateTimeFormat(pattern = "yyyy-MM-dd")
    @ApiModelProperty(name = "dutiesDate",value = "生日",dataType = "LocalDate")
    private LocalDate birthDate;

    /**
     * 年龄
     */
    @Transient
    private Integer age;

    /**
     * 身高
     */
    private Integer high;

    /**
     * 民族
     */
    @Column(length = 36)
    private String nation;

    /**
     * 英语水平
     */
    @Column(length = 16)
    private String englishLevel;

    /**
     * 户籍所在地
     */
    @Column(length = 32)
    private String censusRegister;

    /**
     * 户籍性质
     */
    @Column(length = 8)
    private String censusType;

    /**
     * 健康状况
     */
    @Column(length = 16)
    private String heathInfo;

    /**
     * 婚姻状况
     */
    @Column(length = 16)
    private String marriageInfo;

    /**
     * 政治面貌
     */
    @Column(length = 40)
    private String politicalLandscape;


    /**
     * 国家
     */
    @Column(length = 60)
    private String country;

    /**
     * 籍贯 省
     */
    @Column(length = 40)
    private String province;

    /**
     * 籍贯 市
     */
    @Column(length = 60)
    private String city;

    /**
     * 籍贯 县
     */
    @Column(length = 60)
    private String area;

    /**
     * 现工作单位
     */
    @Column(length = 120)
    private String workCompany;

    /**
     * 现工作医院等级
     */
    @Column(length = 16)
    private String hospitalLevel;

    /**
     * 现任党政管理职务
     */
    @Column(length = 36)
    private String duties;

    @JsonFormat(pattern = "yyyy-MM-dd",timezone="GMT+8")
    @DateTimeFormat(pattern = "yyyy-MM-dd")
    @ApiModelProperty(name = "dutiesDate",value = "现任党政管理职务时间",dataType = "LocalDate")
    private LocalDate dutiesDate;

    /**
     * 三甲医院工作时间（年）
     */
    @ApiModelProperty(name = "workYears",value = "三甲医院工作时间",dataType = "Integer")
    // @NonNull
    private Integer workYears;

    /**
     * 本人是否具有研究生导师资格
     */
    @Column(length = 4)
    private String tutorIntel;

    /**
     * 导师资格时间
     */
    @JsonFormat(pattern = "yyyy-MM-dd",timezone="GMT+8")
    @DateTimeFormat(pattern = "yyyy-MM-dd")
    @ApiModelProperty(name = "tutorIntelDate",value = "导师资格聘任时间",dataType = "LocalDate")
    private LocalDate tutorIntelDate;

    /**
     * 现专业技术资格
     */
    @Column(length = 50)
    private String xzyjszg;



    @JsonFormat(pattern = "yyyy-MM-dd",timezone="GMT+8")
    @DateTimeFormat(pattern = "yyyy-MM-dd")
    @ApiModelProperty(name = "xzyjszgzyGainDate",value = "现专业技术资格取得时间",dataType = "LocalDate")
    private LocalDate xzyjszgzyGainDate;


    /**
     * 现专业技术资格专业名称
     */
    @Column(length = 50)
    private String xzyjszgzymc;
    /**
     * 专业技术职务任职资格
     */
    @Column(length = 16)
    private String zjzwxzdj;

    /**
     * 专业技术职务任职资格等级
     */
    @Column(length = 16)
    private String zjzwxzdjlev;

    /**
     * 现受聘专业技术服务
     */
    @Column(length = 4)
    private String xspzyjszw;

    /**
     * 现专业技术职务聘任时间
     */
    @JsonFormat(pattern = "yyyy-MM-dd",timezone="GMT+8")
    @DateTimeFormat(pattern = "yyyy-MM-dd")
    @ApiModelProperty(name = "xspzyjszwDate",value = "现专业技术职务聘任时间",dataType = "LocalDate")
    private LocalDate xzyjszwDate;

    /**
     * 现专业技术职务聘任专业名称
     */
    @Column(length = 20)
    private String xzyjszwprzymc;

    /**
     * 执业类别  作废
     */
    //@Column(length = 40)
    //private String occupationType;

    /**
     * 执业范围
     */
    @Column(length = 40)
    private String occupationRange;

    /**
     * 受聘学校
     */
    @Column(length = 40)
    private String teachSchool;

    /**
     * 现教师系列专业技术服务
     */
    @Column(length = 16)
    private String teachSchoolPost;


    @JsonFormat(pattern = "yyyy-MM-dd",timezone="GMT+8")
    @DateTimeFormat(pattern = "yyyy-MM-dd")
    @ApiModelProperty(name = "xspzyjszwDate",value = "现教师系列专业技术职务任职时间",dataType = "LocalDate")
    private LocalDate teachSchoolDate;

    //个人信息

    //教育背景
    /**
     * 学习经历
     */
    /*@OneToMany(mappedBy="recruit",fetch = FetchType.EAGER)
    private List<LearnExperience> learnExperiences;*/

    @JsonFormat(pattern = "yyyy-MM-dd",timezone="GMT+8")
    @DateTimeFormat(pattern = "yyyy-MM-dd")
    @ApiModelProperty(name = "firstWorkDate",value = "首次参加工作日期",dataType = "LocalDate")
    private LocalDate firstWorkDate;

    /**
     * 工作经历
     */
    /*@OneToMany(mappedBy="recruit",fetch = FetchType.EAGER)
    private Set<WorkExperience> workExperiences;*/

    /**
     * 规培情况
     */
    @Column(length = 40)
    private String trainInfo;


    /**
     * 规培经历
     */
    /*@OneToMany(mappedBy="recruit",fetch = FetchType.EAGER)
    private Set<TrainExperience> trainExperiences;*/
    //教育背景


    //业绩成果
    /**
     * 学术兼职
     */
    @Column(length = 400)
    private String academicPart;


    /**
     * 获奖情况
     */
    @Column(length = 400)
    private String awards;

    /**
     * 参与科研项目情况
     */
    @Column(length = 400)
    private String scientificProject;

    /**
     * 科研项目汇总
     */
    @Column(length = 400)
    private String scientificProjectCollect;

    /**
     * 第一作者或通讯作者发表论文论著情况
     */
    @Column(length = 400)
    private String publications;


    /**
     * 其他成果
     */
    @Column(length = 400)
    private String otherFinding;


    /**
     * 成果汇总
     */
    @Column(length = 400)
    private String findingCollect;

    /**
     * 业绩
     */
    @Column(length = 400)
    private String performance;


    /**
     * 入选何种人才计划、获得何种人才奖励及时间
     */
    @Column(length = 400)
    private String talentPlan;
    //业绩成果

    /**
     * 备注
     */
    @Column(length = 400)
    private String notes;


    /**
     * 最高学历毕业学校
     */
    @Column(length = 180)
    private String highSchool;

    /**
     * 专业
     */
    @Column(length = 180)
    private String highMajor;
    // 单表获取
   /* @JsonFormat(pattern = "yyyy-MM-dd",timezone="GMT+8")
    @DateTimeFormat(pattern = "yyyy-MM-dd")
    @ApiModelProperty(name = "applyDate",value = "申请日期",dataType = "LocalDate")
    private LocalDate applyDate;*/

    public Integer getAge(){
        if(this.birthDate == null){
            return null;
        }else{
            // LocalDate.now();
            Long until = this.birthDate.until(LocalDate.now(), ChronoUnit.YEARS);
            return until.intValue();
        }
    }
}
